package ecustom.common.util;

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;

import org.apache.log4j.Logger;

public class FileUtil {
	
	private static final Logger log = Logger.getLogger(FileUtil.class);
	
	public static void closeInputStream(InputStream inputStream) {
		if (inputStream == null) return;
		try {
			inputStream.close();
		} catch (IOException e) {
			log.error("closeInputStream() 流关闭失败", e);
		}
	}
	
	public static void closeOutputStream(OutputStream outputStream) {
		if (outputStream == null) return;
		try {
			outputStream.close();
		} catch (IOException e) {
			log.error("closeOutputStream() 流关闭失败", e);
		}
	}
	
	public static void closeReader(Reader reader) {
		if (reader == null) return;
		try {
			reader.close();
		} catch (IOException e) {
			log.error("closeReader() 流关Reader失败", e);
		}
	}
	
	public static boolean isZip(File file) {
		String name = file.getName().toLowerCase();
		return name.endsWith(".zip");
	}
}
